﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HelloWorld.RobotFights
{
    public class InputHandler
    {
        public event EventHandler SpeedUp;
        public event EventHandler SpeedDown;

        public void QueryKeyBoard()
        {
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo kInfo = Console.ReadKey(true);

                switch ( kInfo.Key)
                {
                    case ConsoleKey.Add:
                    case ConsoleKey.OemPlus:
                        OnSpeedUp();
                        break;
                    case ConsoleKey.OemMinus:
                    case ConsoleKey.Subtract:
                        OnSpeedDown();
                        break;
                }
            }
        }

        protected virtual void OnSpeedUp()
        {
            if (this.SpeedUp != null)
                this.SpeedUp(this, EventArgs.Empty);
        }

        protected virtual void OnSpeedDown()
        {
            if (this.SpeedDown != null)
                this.SpeedDown(this, EventArgs.Empty);
        }

    }
}
